#include <iostream>

using namespace std;

const int N = 200005;
typedef long long LL;

int A[N], color[N], c[N];
int n;
LL ans;

void dfs(int u)
{
    if (u == n + 1)
    {
        for (int i = 1; i <= n; i++)
        {
            bool flag = true;
            int num = -1;
            for (int j = 1; j < i; j++)
                if (color[j] == color[i])
                    flag = false, num = A[j];
            if (flag) c[i] = 0;
            else
            {
                if (A[i] == num) c[i] = A[i];
                else c[i] = 0;
            }
        }
        LL sum = 0;
        for (int i = 1; i <= n; i++) sum += c[i];
        ans = max(ans, sum);
        return;
    }
    for (int i = 0; i <= 1; i++)
    {
        color[u] = i;
        dfs(u + 1);
        color[u] = 1 - i;
    }
}

int main()
{
    freopen("color.in", "r", stdin);
    freopen("color.out", "w", stdout);

    int T;
    scanf("%d", &T);
    while (T--)
    {
        ans = 0;
        scanf("%d", &n);
        for (int i = 1; i <= n; i++) scanf("%d", &A[i]);
        dfs(1);
        printf("%lld\n", ans);
    }

    return 0;
}
